package com.demo.server2.controller;

import com.demo.dto.UserModifyDTO;
import com.demo.server2.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by hunter
 *
 * @Description 测试控制层
 */
@RestController
public class TestController {

    @Autowired
    private UserService userService;

    /**
     * 测试接口
     *
     * @return
     */
    @GetMapping("/test")
    public String test() {
        return userService.test();
    }

    /**
     * 测试分布式事务接口, 这里作为被调用方
     *
     * @return
     */
    @PostMapping("/testTransactional")
    public String testTransactional(@RequestBody UserModifyDTO modifyDTO) {
        userService.updateUser(modifyDTO);
        return "success";
    }
}
